<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ include file="dbacess.jsp" %>
<jsp:include page="head.jsp" />
<jsp:include page="header.jsp" />
<%
//create variables for parameters grabbed from input name attribute 
String fname = request.getParameter("fname");
String lname = request.getParameter("lname");
String caddress = request.getParameter("caddress");
String ccity = request.getParameter("ccity");
String cprov = request.getParameter("cprov");
String cpostal = request.getParameter("cpostal");
String cbusphone = request.getParameter("cbusphone");
String cemail = request.getParameter("cemail");
String passwd = request.getParameter("passwd");

String sql = "insert into Customers (CustFirstName, CustLastName,CustAddress,CustCity,CustProv,CustPostal,CustBusPhone,CustEmail, CustPasswd) values ('"+ fname +"','"+ lname +"','" 
+ caddress + "','" + ccity + "','"+ cprov + "','"+ cpostal +"','" + cbusphone +"','"+cemail+"','"+ passwd +"')";

try {
	int action = conn.createStatement().executeUpdate(sql);
	conn.setAutoCommit(true);
	if (action > 0)
	{
		//session.setAttribute("username", fname);
		out.print("Information Saved");
		String redirectURL = "account.jsp";
	    response.sendRedirect(redirectURL);
	}
	else {
		out.print("Information was not saved.");
	}

}
catch (Exception e)
{
	out.println("An Error Occurred!");
	out.println(e);
	e.printStackTrace();
	} 
finally {
	conn.close();
}

%>

</div><!-- END Main -->
<!-- the row-end div is to take care of the floating issue -->
<div class="row-end"></div>



<div id="push"></div>
</div><!-- END OF Spacer -->
<jsp:include page="footer.jsp" />